home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Online
/
News
/
Thor
/
HD-Install
/
thor25_arexx.lha
/
MsgSplit.thor
< prev
next >
Wrap
Text File
|
1996-10-26
|
5KB
|
172 lines
/* $VER: MsgSplit.thor 1.3 (14.9.95)
**
** Written by Stelios Melissakis for Thor 2.x.
**
**
** Many-many thanks to Kjell Irgens & the rest of Thor Team :)
**
**/
Options Results
Arg MaxSize .
Signal on Syntax
Signal on Halt
Signal on Break_C
If (MaxSize = '' | MaxSize = '?') Then
Do
Say 'MsgSplit.thor v1.3 (14.9.95)'
Say '© 1995 Stelios Melissakis'CR
Say 'Usage: MsgSplit.thor MAXSIZE/A'
Exit(0)
End
CR = '0a'x
/* You can change these two variables */
/* But be careful! */
ContNextMsg = CR || '<< Continued in Next Message >>' || CR
ContPrevMsg = '<< Continued from Previous Message >>'
/* No more user changes, after this line, please :) */
Eve_EnterMsg = 0
Eve_ReplyMsg = 1
EDB_Deleted = 0
UT_MsgFile = 1
Drop BBSData.
Drop EventData.
Drop EventTags.
Drop UniqueStem.
Drop CurStem.
Window = 0
CurMsg = 0
adrstr = ' ' || Address() || ' ' || Show('P',,)
If Pos(' THOR.',adrstr) > 0 Then
ThorPort = Word(SubStr(adrstr, Pos(' THOR.',adrstr)+1),1)
Else
Do
Say 'No THOR port found!'
Exit(0)
End
If ~Show('l','rexxsupport.library') Then
If ~AddLib('rexxsupport.library',0,-30) Then
Exit(25)
If ~Show('p', 'BBSREAD') Then
Do
Address Command
"Run >NIL: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
End
Address(ThorPort)
CurrentSystem CurStem
If (rc = 30) Then Call Fail
Address("BBSREAD")
GetBBSData '"'CurStem.BBSName'"' Stem BBSData
If (rc ~= 0) Then Call Fail
If BBSData.NumEvents = "BBSDATA.NUMEVENTS" Then Exit(0)
Address(ThorPort)
OpenProgress Title '"Splitting messages"' Total BBSData.NumEvents ProgressCharWidth 40
If (rc = 0) Then Window = Result
Else Call Fail
Do n = BBSData.FirstEvent To BBSData.LastEvent
Address("BBSREAD")
ReadBREvent bbsname '"'CurStem.BBSName'"' EventNR n TagsStem EventTags DataStem EventData
If (rc ~= 0) Then Call Fail
If (~BITTST(EventData.Flags, EDB_Deleted)) Then CurMsg = CurMsg + 1
If (~BITTST(EventData.Flags, EDB_Deleted) & ((EventData.EventType = Eve_EnterMsg) | (EventData.EventType = Eve_ReplyMsg))) Then
Do
FName = BBSData.BBSPath || EventTags.MsgFile
FSize = FileSize(FName)
If FSize > MaxSize Then
Do
Drop WtStem.
Pieces = FSize % MaxSize
If (((FSize / MaxSize) - (FSize % MaxSize)) ~= 0) Then Pieces = Pieces + 1
bc = 1
If Open(Source, FName, 'R') Then
Do
Do Until EOF(Source)
If ~Open(Dest, 'T:Thor_TMP_Msg', 'W') Then Call Fail
If bc > 1 Then Call WriteLn(Dest, ContPrevMsg || ' (' || bc || '/' || Pieces || ')' CR)
TotSize = 0
Do Until (TotSize > (MaxSize - 170)) | EOF(Source)
TotSize = TotSize + WriteLn(Dest, ReadLn(Source))
End
If ~EOF(Source) Then Call WriteLn(Dest, ContNextMsg)
Call Close(Dest)
UniqueMsgFile BBSName '"'CurStem.BBSName'"' Stem UniqueStem UseTag UT_MsgFile FromFile 'T:Thor_TMP_Msg'
If (rc ~= 0) Then Call Fail
WtStem.ToName = EventTags.ToName
WtStem.Subject = EventTags.Subject
WtStem.Conference = EventTags.Conference
WtStem.MsgFile = UniqueStem.FilePart
WtStem.Private = EventTags.Private
WtStem.Date = EventTags.Date
WtStem.RefNr = EventTags.RefNr
WtStem.RefOrginalNr = EventTags.RefOrginalNr
If EventTags.PGPSignID ~= "EVENTTAGS.PGPSIGNID" Then WtStem.PGPSignID = EventTags.PGPSignID
If EventTags.PGPEncryptID ~= "EVENTTAGS.PGPENCRYPTID" Then WtStem.PGPEcryptID = EventTags.PGPEcryptID
WriteBREvent BBSName '"'CurStem.BBSName'"' Event EventData.EventType Stem WtStem
If (rc ~= 0) Then Call Fail
bc = bc + 1
End
Call Close(Source)
End
Else Call Fail
UpdateBREvent BBSname '"'CurStem.BBSName'"' EventNr n SetDeleted
If (rc ~= 0) Then Call Fail
End
End
Address(ThorPort)
UpdateProgress Req Window Current CurMsg PT '"Message 'CurMsg' of 'BBSData.NumEvents'(OrgEvent:'n')"'
If (rc ~= 0) Then Call Fail
End
Fail:
Syntax:
Signal Off Syntax
If (rc >30) Then Say 'Error in line 'SIGL': ' ErrorText(rc) ||CR|| SourceLine(SIGL)
If Thor.LastError ~= 'THOR.LASTERROR' Then Say Thor.LastError
If BBSRead.LastError ~= 'BBSREAD.LASTERROR' Then Say BBSRead.LastError
Halt:
Break_C:
FileSrch = Show('F',,)
If Pos('SOURCE',FileSrch) ~= 0 Then Call Close(Source)
If Pos('DEST',FileSrch) ~= 0 Then Call Close(Dest)
If (Window ~= 0) Then
Do
Address(ThorPort)
CloseProgress Req Window
Window = 0
End
If Exists("T:Thor_TMP_Msg") Then
Call Delete("T:Thor_TMP_Msg")
Exit(0)
/***************************************************************************/
/* Procedures */
/***************************************************************************/
FileSize: Procedure
Arg fn
FData = StateF(fn)
FSpc = Pos(' ', FData)
LSpc = Pos(' ', FData, FSpc + 1)
Return SubStr(FData, FSpc+1, LSpc-FSpc-1)
/***************************************************************************/